home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / util / cli / wrap.lha / Wrap.gc < prev    next >
Text File  |  1996-12-07  |  8KB  |  295 lines

  1. G4C   - Wrap.gc - Gui4Cli GUI for the Wrap command.
  2.  
  3. ; This is a GUI script for the "Wrap" CLI command
  4. ; GUI script written by Graham Maddox & D.Keletsekis
  5. ; Wrap command by D.Keletsekis
  6.  
  7. ; This GUI needs an other program called Gui4Cli (V2.2) to run it.
  8. ; Gui4Cli is a GUI runner and can be downloaded from :
  9. ; Aminet, under Dev/Gui/Gui4Cli.lha 
  10. ; or at http://users.hol.gr/~dck/gcmain.htm
  11.  
  12. ; With this GUI the Wrap command becomes very usefull, handling
  13. ; multiple file selection and having the abilty to wrap to any width
  14. ; between 10 and 200 columns. (You could increase it if needed).
  15. ; Also handles MessyDOS text and is extremely easy to use.
  16.  
  17. ; You run it by clicking on it's icon, or typing from the CLI
  18. ; > run gui Wrap.gc
  19.  
  20.  
  21. ; ----------------- The window
  22.  
  23. WinBig -1 -1 440 150 'TextWrap v2.0'
  24. WinType 11110001  ; it's resizable & font sensitive with all gadgets
  25.  
  26. ; ----------------- General events
  27.  
  28. xOnLoad        ; Set the default values
  29. tw_ext = 1    ; Add extensions
  30. tw_newdir = 0        ; do not save to new dir
  31. setgad wrap.gc 2 off    ; and turn off the dir-select gadgets
  32. setgad wrap.gc 3 off
  33. tw_dest = RAM:    ; default dir to save in
  34. tw_para = 1       ; leave paragraphs alone
  35. tw_skeol = 2    ; how many end of line characters to skip
  36. tw_strhr = 0    ; don't strip carriage returns (CRs)
  37. tw_addcr = 0    ; don't add CRs
  38. tw_tabflag = 0  ; delete all tabs
  39. tw_tab = 4    ; default tab -> spaces length
  40. setgad wrap.gc 6 off
  41. tw_colflag = 1  ; Yes, change line length.
  42. tw_col = 75     ; to 75 characters per line
  43. run 'resident c:wrap pure add'
  44. guiopen wrap.gc
  45.  
  46.  
  47. xOnClose
  48. delvar tw_#?
  49. guiquit wrap.gc
  50. guiquit wrapread.g
  51. run 'resident wrap remove'
  52.  
  53.  
  54. ; Some fancy boxes to separate the functions into sections.
  55.  
  56. box 200 0 240 51 out button
  57. box 200 52 240 36 out button
  58. box 200 89 240 35 out button
  59. box 200 125 240 25 out button
  60.  
  61. ; dig these for flashy buttons then - I've broken my own record... 8)
  62.  
  63. box 8 134 184 14 in button
  64.  
  65.  
  66. ; ---------------- The directory listview for choosing files to convert
  67.  
  68. xlistview 0 0 200 135 "" tw_select SYS: 10 dir
  69. gadid 1
  70. lvdirhook 1
  71. gadfont topaz.font 8 000           ; change the font if you like.. Or don't. I don't care... 8)
  72. guiopen wrapread.g
  73.  
  74. xlvdirhook 1
  75. setwintitle wrap.gc 'TextWrap $$LV_DIR                         '
  76.  
  77.  
  78. ; ---------------- move about buttons for the dir listview
  79.  
  80. xbutton  10 135 45 12 _Par
  81. lvdir wrap.gc 1 parent
  82. setwintitle wrap.gc 'TextWrap $$LV_DIR                         '
  83.  
  84. xbutton  55 135 45 12 _Vol
  85. lvdir wrap.gc 1 disks
  86. setwintitle wrap.gc 'TextWrap 2.0'
  87.  
  88. xbutton  100 135 45 12 _All
  89. lvdir wrap.gc 1 all
  90.  
  91. xbutton  145 135 45 12 _None
  92. lvdir wrap.gc 1 none
  93.  
  94.  
  95. ; ---------------- Do we want to add extensions to the files ?
  96.  
  97. xcheckbox 400 5 26 11 'Add ".wrap" extension' tw_ext 1 0 ON
  98.  
  99.  
  100. ; ---------------- Do we want to save them in an other dir ?
  101.  
  102. xcheckbox 400 17 26 11 'Save to new directory' tw_newdir 1 0 OFF
  103. if $tw_newdir = 1
  104.    setgad wrap.gc 2 on
  105.    setgad wrap.gc 3 on
  106. else
  107.    setgad wrap.gc 2 off
  108.    setgad wrap.gc 3 off
  109. endif
  110.  
  111. ; Text in for new directory
  112.  
  113. xTextIn  210 31 180 15 "" tw_dest "RAM:" 512        ; destination dir
  114. gadid 3
  115.  
  116. ; add a browse button to save typing
  117.  
  118. xbutton 390 31 40 15 "Dir"
  119. gadid 2
  120. reqfile -1 -1 300 -40 "Destination Dir..." dir tw_dest SYS:
  121. update Wrap.gc 3 $tw_dest
  122.  
  123. ; ---------------- paragraph options. default is off
  124.  
  125. xcheckbox 210 57 26 11 "Paragraph" tw_para 1 0 on
  126. gadtitle right
  127. if $tw_para = 1
  128.     setgad wrap.gc 4 on
  129. else
  130.     setgad wrap.gc 4 off
  131. endif
  132.  
  133. xhslider 357 57 50 11 "EOLs" tw_skeol 0 30 2 %1ld
  134. gadtitle left
  135. gadid 4
  136.  
  137. ; ------------------- checkboxes for adding/stripping hard returns. 
  138. ; Default (unchecked) is to leave them alone.
  139. ; Check both of them if you want to re-warp PC files
  140.  
  141. xcheckbox 210 72 26 11 "StripCR" tw_strhr 1 0 off
  142. gadtitle right
  143.  
  144. xcheckbox 320 72 26 11 "AddCR" tw_addcr 1 0 off
  145. gadtitle right
  146.  
  147.  
  148. ; =====================================================================
  149. ; Now the sliders for tab settings and width. Default is tab=4 width=75
  150. ; If these are set to off, Tabs & line length will be left alone.
  151. ; NOTE : Max line length that wrap can deal with is 1000 characters.
  152.  
  153. xcheckbox 210 93  26 11 "Tabs" tw_tabflag 1 0 off
  154. gadtitle right
  155. if $tw_tabflag = 0
  156.    setgad wrap.gc 6 off
  157. else
  158.    setgad wrap.gc 6 on
  159. endif
  160.  
  161. xhslider 290 93  115 11 "" tw_tab 0 16 4 %1ld
  162. gadid 6
  163.  
  164. ; --- length slider
  165.  
  166. xcheckbox 210 108 26 11 "Length" tw_colflag 1 0 on
  167. gadtitle right
  168. if $tw_colflag = 0
  169.    setgad wrap.gc 7 off
  170. else
  171.    setgad wrap.gc 7 on
  172. endif
  173.  
  174. xhslider 290 108 115 11 "" tw_col 10 200 75 %1ld
  175. gadid 7
  176.  
  177.  
  178. ; ====================================================================
  179. ; Do yes do, that thing you do, so weeeelllll... (refrain)
  180.  
  181. xbutton 270 130 80 15 START
  182. tw_stopflag = 0            ; reset abort flag
  183. lvmulti wrap.gc 1 first
  184. if $tw_select = ""
  185.    ezreq "I would.. if I had\nsome files.." OK ""
  186.    stop
  187. endif
  188. if $tw_ext = 0            ; check & warn if files will be overwriten
  189.    if $tw_newdir = 0
  190.       ezreq 'With the current settings\nselected files will be\nOverWriten !\n\nIf any file is not a pure\ntext file, it may be trashed!\n\nAre you sure ?\n' "Continue|CANCEL" tw_choice
  191.       if $tw_choice = 0
  192.          stop
  193.       endif
  194.    endif
  195. endif
  196. guiwindow wrap.gc wait
  197. gosub wrap.gc setup                    ; construct the command line
  198. launch 1 'wrap $tw_select $tw_options'        ; and launch the first file
  199.  
  200.  
  201. xOnReturn 1            ; upon returning, launch the next file
  202. lvmulti wrap.gc 1 off
  203. if $tw_stopflag = 1        ; check if user has aborted meanwhile
  204.    guiwindow wrap.gc resume
  205.    lvdir wrap.gc 1 refresh
  206.    stop
  207. endif
  208. lvmulti wrap.gc 1 next
  209. if $tw_select > ""
  210.    gosub wrap.gc setup
  211.    launch 1 'wrap $tw_select $tw_options'
  212. else
  213.    guiwindow wrap.gc resume
  214.    if $tw_newdir = 1
  215.       lvdir wrap.gc 1 #$tw_dest
  216.       setwintitle wrap.gc '$tw_dest                                    '
  217.    else
  218.       lvdir wrap.gc 1 refresh
  219.    endif
  220. endif
  221.  
  222.  
  223. xroutine setup            ; construct the options command line
  224. tw_options = ""
  225. extract tw_select file tw_file
  226. if $tw_ext = 1
  227.    extract tw_file unquote tw_file2
  228.    appvar  tw_file2 .wrap               ; add the file extension
  229.    tw_file =  '\"$tw_file2\"'
  230. endif
  231. if $tw_newdir = 1
  232.    JoinFile $tw_dest $tw_file tw_file   ; save to new dir
  233. else
  234.    extract tw_select path tw_path
  235.    JoinFile $tw_path $tw_file tw_file   ; or to the same dir
  236. endif
  237. tw_options = '$tw_file '        ; this is our correct file name
  238. if $tw_para = 1
  239.    appvar tw_options 'PARA=$tw_skeol '  ; paragraph wraping ?
  240. endif
  241. if $tw_strhr = 1
  242.     appvar tw_options 'StripCR '    ; strip CRs ?
  243. endif
  244. if $tw_addcr = 1
  245.     appvar tw_options 'AddCR '        ; add CRs ?
  246. endif
  247. if $tw_tabflag = 1
  248.     appvar tw_options 'TAB=$tw_tab '    ; convert tabs ?
  249. endif
  250. if $tw_colflag = 1
  251.     appvar tw_options 'L=$tw_col'    ; wrap file ?
  252. endif
  253.  
  254.  
  255. ; ------------------------ Stop processing the rest of the files
  256.  
  257. xButton 350 130 80 15 _STOP
  258. tw_stopflag = 1
  259.  
  260.  
  261. ; ------------------------ If the worst happens..
  262.  
  263. xOnFail
  264. guiwindow wrap.gc resume
  265. lvdir wrap.gc 1 refresh
  266. ezreq "Error wraping file :\n$tw-file" OK ""
  267.  
  268.  
  269. ; ------------------------- Must tell everyone how great I am..... 8)
  270.  
  271. xbutton 220 130 26 15  _?
  272. EzReq "TextWrap 2.0\n\nBy :\nG.Maddox & D.Keletsekis\n\nFor use with the c:Wrap\ncommand, by D.Keletsekis\n" "Who cares.." opt
  273.  
  274. ; ######################################################################
  275.  
  276. Newfile wrapread.g   ; a small gui for reading your file
  277.  
  278. WinBig 0 11 0 -13 ""
  279. WinSmall 0 -1 150 21
  280. WinType 11110001
  281.  
  282. xOnOpen
  283. setwintitle wrapread.g "Loading ..."
  284. lvchange wrapread.g 1 $tw_select
  285. setwintitle wrapread.g '$tw_select                                  '
  286.  
  287. xOnClose
  288. lvchange wrapread.g 1 ""   ; so as not to keep it memory
  289.  
  290. xListview  0 0 0 0 "" "" "" 10 NUM
  291. gadid 1
  292.  
  293.  
  294.  
  295.